package com.ihd.ihardware.db;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;

@Database(entities = {Weight.class}, version = 1, exportSchema = false)
public abstract class MDataBase extends RoomDatabase {

    private static final String DB_NAME = "MDataBase.db";
    private static volatile MDataBase instance;

    public static synchronized MDataBase getInstance(Context context) {
        if (instance == null) {
            instance = create(context);
        }
        return instance;
    }

    private static MDataBase create(final Context context) {
        return Room.databaseBuilder(
                context,
                MDataBase.class,
                DB_NAME).build();
    }

    public abstract WeightDao getWeightDao();
}
